<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body style="margin: 0">
<div id="app">
    <el-container>
        <el-aside width="230px" style="background-color: #545c64">
            <!--外设小屋-->
            <h1 style="color:white;margin-left: 20px" >外设小屋后台管理系统</h1>
                <el-menu
                        style="width: 230px;height: 700px;"
                        default-active="2"
                        class="el-menu-vertical-demo"
                        @select="handleSelect"
                        background-color="#545c64"
                        text-color="#fff"
                        active-text-color="#ffd04b">
                    <!--用户列表-->
                    <el-submenu index="1">
                        <template slot="title">
                            <i class="el-icon-user"></i>
                            <span>用户管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="1-1">用户列表</el-menu-item>
                        </el-menu-item-group>
                    </el-submenu>

                    <!--商品分类管理-->
                    <el-submenu index="2">
                        <template slot="title">
                            <i class="el-icon-s-flag"></i>
                            <span>商品分类管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="2-1">商品分类管理</el-menu-item>
                            <el-menu-item index="2-2">添加商品分类</el-menu-item>
                        </el-menu-item-group>
                    </el-submenu>

                    <!--商品管理-->
                    <el-submenu index="3">
                        <template slot="title">
                            <i class="el-icon-s-goods"></i>
                            <span>商品管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="3-1">商品列表</el-menu-item>
                            <el-menu-item index="3-2">添加商品</el-menu-item>
                        </el-menu-item-group>
                    </el-submenu>

                    <!--订单管理-->
                    <el-submenu index="4">
                        <template slot="title">
                            <i class="el-icon-s-order"></i>
                            <span>订单管理</span>
                        </template>
                        <el-menu-item-group>
                            <el-menu-item index="4-1">订单列表</el-menu-item>
                        </el-menu-item-group>
                    </el-submenu>
                </el-menu>
        </el-aside>
        <el-container>
            <el-header>
                <span style="float: right;margin-top: 15px">
                    欢迎XXX回来
                    <el-button type="danger"><a href="javascript:void (0)" @click="logout()"></a>退出登录</el-button>
                </span>
            </el-header>

            <el-main style="background-color: #f3f3f3">
                <!--用户列表-->
                <el-table v-if="currentIndex=='1-1'"
                          :data="userArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="username" label="用户名" width="180"></el-table-column>
                    <el-table-column prop="nickname" label="昵称" width="180"></el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行对对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应
                        -->
                        <template slot-scope="scope">
                            <el-button
                                    size="mini"
                                    type="danger"
                                    @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>

                <!--分类列表-->
                <el-table v-if="currentIndex=='2-1'"
                          :data="categoryArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="name" label="类别" width="180"></el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行对对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应
                        -->
                        <template slot-scope="scope">
                            <el-button
                                    size="mini"
                                    type="danger"
                                    @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>

                <!--商品列表-->
                <el-table v-if="currentIndex=='3-1'"
                          :data="productArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="title" label="商品标题" width="200"></el-table-column>
                    <el-table-column prop="price" label="价格" width="80"></el-table-column>
                    <el-table-column prop="oldPrice" label="原价" width="80"></el-table-column>
                    <el-table-column prop="saleCount" label="销量" width="80"></el-table-column>
                    <el-table-column
                            label="商品图片"
                            width="100">
                        <template slot-scope="scope">
                            <!--scope.row代表当前行对应数组中的对象-->
                            <img :src="scope.row.url" width="100%" alt="">
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行对对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应
                        -->
                        <template slot-scope="scope">
                            <el-button
                                    size="mini"
                                    type="danger"
                                    @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>

                <!--订单列表-->
                <el-table v-if="currentIndex=='4-1'"
                          :data="ordersArr"
                          style="width: 100%">
                    <!--type=index 设置这一列显示的内容为编号-->
                    <el-table-column type="index" label="编号"></el-table-column>
                    <el-table-column prop="nickname" label="昵称" width="180">    </el-table-column>
                    <el-table-column prop="phone" label="手机号" width="180"></el-table-column>
                    <el-table-column prop="created" label="下单时间" width="80"></el-table-column>
                    <el-table-column prop="state" label="订单状态" width="80"></el-table-column>
                    <el-table-column label="操作">
                        <!--scope里面装着当前行对对应的对象信息
                        scope.$index 得到当前行对应的对象在数组中的下标
                        scope.row 得到当前行对应
                        -->
                        <template slot-scope="scope">
                            <el-button
                                    size="mini"
                                    type="danger"
                                    @click="handleDelete(scope.$index, scope.row)">修改</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-main>
        </el-container>
    </el-container>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                currentIndex:"1-1",
                userArr:[{username:"hh",nickname:"张三"}],
                categoryArr:[{name:"鼠标"},{name:"键盘"}],
                productArr:[{title:"森马牛仔裤女宽松慢跑裤运动风2022春季新款显瘦束脚长裤复古",price:233,oldPrice:598,url:"img/bc.jpg",saleCount:2342},
                    {title:"茵曼马甲连衣裙两件套春季新款娃娃领色织格长袖背心裙套装",price:233,oldPrice:598,url:"img/bc.jpg",saleCount:2342},
                    {title:"雪中飞墨绿色短袖t恤女夏2022新款纯棉半袖打底体恤夏季上衣潮ins",price:233,oldPrice:598,url:"img/bc.jpg",saleCount:2342}],
                ordersArr:[{nickname:"张三",phone:12324646,created:"2022年",state:"未付款"},
                        {nickname:"张三",phone:12324646,created:"2022年",state:"已付款"},
                        {nickname:"张三",phone:12324646,created:"2022年",state:"已发货"}]
            }
        },
        methods:{
            logout(){
              if (confirm("你确定要退出登录吗?")){
                  axios.get("/logout/admin").then(function () {
                      location.href="/adminlogin.html"
                  })
              }
            },
            handleSelect(key,keyPath){
                if (key=="2-2"){
                    v.$message("添加商品分类");
                }else if (key=="3-2"){
                    v.$message("添加轮播图");
                }else {
                    v.currentIndex = key;
                }
            }
        }
    })
</script>
</html>